#include "logwindow.h"
#include "ui_logwindow.h"
#include "QDateTime"

LogWindow::LogWindow(QWidget *parent) : QMainWindow(parent),
                                        ui(new Ui::LogWindow)
{
    ui->setupUi(this);
}

LogWindow::~LogWindow()
{
    delete ui;
}
/*************************************************
**Function: logToLog(QString str)
**Description: 将日志内容及时间显示到文本框
**Input: 日志内容,QString类型
*************************************************/
void LogWindow::logToLog(QString str)
{
    ui->textBrowser->moveCursor(QTextCursor::End);
    ui->textBrowser->insertHtml(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss: ") + str + "<br>");
    ui->textBrowser->moveCursor(QTextCursor::End);
}
/*************************************************
**Function: on_copyButton_clicked()
**Description: 复制日志内容
*************************************************/
void LogWindow::on_copyButton_clicked()
{
    ui->textBrowser->selectAll();
    ui->textBrowser->copy();
}
/*************************************************
**Function: on_okButton_clicked()
**Description: 关闭（隐藏）日志窗口
*************************************************/
void LogWindow::on_okButton_clicked()
{
    closeThis();
}
